﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sale.DataAccess.Repository
{
    public class OrderRepository : BaseRepository
    {
        public double GetPendingOrderedMerchandiseCount(int merchandiseId)
        {
            var list = Context.OrderDetails.Where(e => e.MerchandiseId == merchandiseId
                && !e.Order.ActualShippingDate.HasValue);

            if (list.Count() == 0) return 0;
            return list.Sum(e => e.Quantity);
        }
    }
}
